//
//  LogFirstTimeViewController.m
//  marrymarry
//
//  Created by lsj on 16/9/13.
//  Copyright © 2016年 cf. All rights reserved.
//



static NSString * logFirstCellID =  @"LogFirstTimeTableViewCell";
#import "LogFirstTimeViewController.h"
#import "LogFirstTimeTableViewCell.h"
#import "PostImageView.h"
#import "BaseTabBarVC.h"
#import "HZLocation.h"
#import "HZAreaPickerView.h"
#import "ZLPhotoActionSheet.h"
#import "ZLShowBigImage.h"
#import "ZLDefine.h"
#import "CFinfoModel.h"

@interface LogFirstTimeViewController ()<UITableViewDataSource,UITableViewDelegate,UIPickerViewDataSource,UIPickerViewDelegate,HZAreaPickerDelegate,UIScrollViewDelegate>
{
     NSString * _MarryTimeStr;
    NSString *_dateStr;
    NSString * _tallStr;
    NSString * _earnMoneyStr;
    NSString * _marryStatus;
    NSString * _workStr;
    NSString * _xinZuoStr;
    NSString * _NBStr;
}
@property (weak, nonatomic) IBOutlet UIView *baseView;
@property (weak, nonatomic) IBOutlet UITableView *myTableView;
@property (weak, nonatomic) IBOutlet UIButton *readyBtn;
@property (weak, nonatomic) IBOutlet UIImageView *AddPhotoView;
@property (weak, nonatomic) IBOutlet UILabel *detailLabel;
@property (weak, nonatomic) IBOutlet UIView *headImgView;

@property (nonatomic, strong) PostImageView *postImageView;
@property (strong , nonatomic) NSMutableArray * dataArry;
@property (strong , nonatomic) NSMutableArray * marryedTimeArry;
@property (strong , nonatomic) NSMutableArray * howTallArry;
@property (strong , nonatomic) NSMutableArray * workWhereArry;
@property (strong , nonatomic) NSMutableArray * yearMoneyArry;
@property (strong , nonatomic) NSMutableArray * workArry;
@property (strong , nonatomic) NSMutableArray * marryedStatusArry;

@property (weak, nonatomic) IBOutlet UIPickerView *myPickView;
@property (weak, nonatomic) IBOutlet UIDatePicker *datePickView;
@property (weak, nonatomic) IBOutlet UILabel *backLabel;

@property (weak, nonatomic) IBOutlet UIButton *finishBtn;
@property (weak, nonatomic) IBOutlet UIView *backGrayView;
@property (weak, nonatomic) IBOutlet UIScrollView *imgScrollView;
@property (strong, nonatomic) UIPickerView * pickNewView;
@property (strong,nonatomic) HZLocation *hzLocation;
@property (strong, nonatomic) HZAreaPickerView *locatePicker;
@property (strong, nonatomic) NSString *areaValue;
@property (strong,nonatomic) UIImageView * imgView;
@property (strong , nonatomic) NSArray * selectPicArry;
@property (nonatomic, strong) NSArray<ZLSelectPhotoModel *> *lastSelectMoldels;
@property (nonatomic, strong) NSArray *arrDataSources;
@property (nonatomic,strong) CFinfoModel * model;
@end

@implementation LogFirstTimeViewController

///选择存储img的数组
-(NSArray *)selectPicArry
{
    if (!_selectPicArry) {
        _selectPicArry = [NSArray new];
    }
    return _selectPicArry;
}

///期望结婚时间数组
-(NSMutableArray *)marryedTimeArry
{
    if (!_marryedTimeArry) {
        _marryedTimeArry = [NSMutableArray new];
        _marryedTimeArry = [[NSMutableArray alloc]initWithArray:@[@"半年内",@"一年内",@"两年内"]];
    }
    return _marryedTimeArry;
}
///身高尺寸
-(NSMutableArray *)howTallArry
{
    if (!_howTallArry) {
        _howTallArry = [NSMutableArray new];
        for (int i = 140; i<=200; i++) {
            NSString * howTallStr = [NSString stringWithFormat:@"%dcm",i];
            [_howTallArry addObject:howTallStr];
        }
        
    }
    return _howTallArry;
}
///年收入
-(NSMutableArray*)yearMoneyArry
{
    if (!_yearMoneyArry) {
        _yearMoneyArry = [[NSMutableArray alloc]initWithArray:@[@"10W以下",@"10W~20W",@"20W~30W",@"30W~50W",@"50W~100W",@"1OOW以上"]];
    }
    return _yearMoneyArry;
}

///婚姻状况
-(NSMutableArray*)marryedStatusArry
{
    if (!_marryedStatusArry) {
        _marryedStatusArry = [[NSMutableArray alloc]initWithArray:@[@"未婚",@"离异",@"丧偶"]];
    }
    return _marryedStatusArry;
}
///职业
-(NSMutableArray *)workArry
{
    if (!_workArry) {
        _workArry = [[NSMutableArray alloc]initWithArray:@[@"公务员",@"教师",@"IT业",@"个体户",@"企业家",@"公司管理",@"金融业",@"科研",@"医生",@"护士",@"自由业",@"艺术",@"撰稿人",@"电视媒体",@"设计师",@"律师",@"服务员",@"财务",@"司机",@"技工",@"务农",@"运输",@"社会活动",@"贸易",@"军人",@"其它"]];
    }
    return _workArry;
}


-(NSMutableArray *)dataArry
{
    if (!_dataArry) {
        _dataArry = [NSMutableArray new];
        _dataArry = [[NSMutableArray alloc]initWithArray:@[@"期望结婚时间",@"出生日期",@"身高",@"工作生活所在",@"年收入",@"职业",@"婚姻状态"]];
    }
    return _dataArry;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = YES;
    self.navigationController.navigationBar.hidden = YES;
     self.model = [CFinfoModel new];
    [self setUI];
}


-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    _marryStatus = @"请选择";
    _earnMoneyStr = @"请选择";
    self.areaValue = @"请选择";
    _dateStr = @"请选择";
    _MarryTimeStr = @"请选择";
    _tallStr  = @"请选择";
    _workStr = @"请选择";
}

-(void)setUI
{
    
    self.baseView.layer.cornerRadius = 5;
    self.readyBtn.layer.cornerRadius= 5;
    self.AddPhotoView.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(addphoto)];
    [self.AddPhotoView addGestureRecognizer:tap];

    
   

}
-(void)addphoto
{

    self.detailLabel.hidden = YES;
    ZLPhotoActionSheet *actionSheet = [[ZLPhotoActionSheet alloc] init];
    //设置照片最大选择数
    actionSheet.maxSelectCount = 5;
    //设置照片最大预览数
    actionSheet.maxPreviewCount = 20;
    weakify(self);
    [actionSheet showWithSender:self animate:YES lastSelectPhotoModels:self.lastSelectMoldels completion:^(NSArray<UIImage *> * _Nonnull selectPhotos, NSArray<ZLSelectPhotoModel *> * _Nonnull selectPhotoModels) {
        strongify(weakSelf);
        strongSelf.arrDataSources = selectPhotos;
        strongSelf.lastSelectMoldels = selectPhotoModels;
        NSLog(@"%@", selectPhotos);
        self.selectPicArry = strongSelf.arrDataSources;
        for (int i =0; i<strongSelf.arrDataSources.count; i++) {
            self.imgView = [UIImageView new];
            self.imgView.frame = CGRectMake(0+80*i+2*i,0,80,80);
            self.imgView.image = strongSelf.arrDataSources[i];
            self.imgView.tag = i;
            [self.imgScrollView addSubview:self.imgView];
            self.imgView.userInteractionEnabled = YES;
            CFUITapGestureRecognizer * imgbigTap = [[CFUITapGestureRecognizer alloc]initWithTarget:self action:@selector(imgbig:)];
            imgbigTap.tapImgView = self.imgView;
            [self.imgView addGestureRecognizer:imgbigTap];
            
        }
      
        self.imgScrollView.contentSize = CGSizeMake(self.selectPicArry.count * (80+2), 0);
        
    }];
    
    
}


-(void)imgbig:(CFUITapGestureRecognizer*)imgTap
{
    [ZLShowBigImage showBigImage:imgTap.tapImgView];
}


#pragma mark ------------点击了我准备好了
- (IBAction)readyButtonDidSelect:(UIButton *)sender {

    
    if (self.selectPicArry.count == 0){
    if (self.selectPicArry.count>0)
    {
//        [self goSaveThePic];
    }else
    {
//        请上至少一张照片
//        提示
        UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"请上传至少一张照片" preferredStyle:UIAlertControllerStyleAlert];
        [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        }]];
        [self presentViewController:alert animated:YES completion:nil];
        return;
    }
    }
    
    NSMutableDictionary * readDic = [NSMutableDictionary new];
    NSMutableDictionary * infoDic = [Tools getValueFromNSUserDefaultsByKey:MY_NET_INFO_DIC];
    readDic = [NSMutableDictionary dictionaryWithDictionary:infoDic];
    
    
    NSArray * timeStrArry = [_dateStr componentsSeparatedByString:@"-"];
    NSInteger month = [timeStrArry[1] integerValue];
    NSInteger dayth = [timeStrArry[2] integerValue];
    _xinZuoStr=[CFinfoModel calculateConstellationWithMonth:month day:dayth];
    NSLog(@"%@",_xinZuoStr);
    NSMutableDictionary * mySendDic = [NSMutableDictionary new];
    NSString * myidStr = [NSString stringWithFormat:@"%@",readDic[@"id"]];
    NSArray * CheckArry = @[_MarryTimeStr,_dateStr,_tallStr,self.areaValue,_earnMoneyStr,_workStr,_marryStatus,_xinZuoStr,myidStr];
    NSArray * checkKeyArry = @[WANT_MARRY_TIME_KEY,BIRTH_TIME_KEY,TALL_KEY,WORK_PLACE_KEY,EARN_MONEY_KEY,WORK_KEY,MARRY_STATUS,XINZUO_KEY,USERID];
    for (int i = 0; i<CheckArry.count; i++) {
        if ([CheckArry[i] isEqualToString:@"请选择"]) {
            [self sendAlertMessage:self.dataArry[i]];
            return;
        }else
        {
            
            [mySendDic setObject:CheckArry[i] forKey:checkKeyArry[i]];
        }
    }
    if (readDic != nil) {
//        NSDictionary *finialDic = [NSDictionary new];
//        finialDic = [NSDictionary dictionaryWithDictionary:readDic];
//        [Tools syncNSUserDeafaultsByKey:MY_NET_INFO_DIC withValue:(NSDictionary *)finialDic];
        

        
        
        [[LJFNetworkingManager shareManager] POST:FINISHINFO_URL upLoadImages:self.selectPicArry parameters:mySendDic success:^(id returnData, int code, NSString *msg) {
            NSLog(@"%@",returnData);
//            BaseTabBarVC *baseVC = [[BaseTabBarVC alloc]init];
            [self requestTheNetWith:nil andURL:MYALLINFO_URL andDic:@{@"id":[Tools getValueFromNSUserDefaultsByKey:USERID]}];
//            [self presentViewController:baseVC animated:YES completion:nil];
            
            
        } failure:^(NSError *error) {
            
        } showHUD:self.view];

        
        
       
       
    }
    
    
    
    
}


#pragma mark --------------网络请求
-(void)requestTheNetWith:(NSArray *)myRequestArry andURL:(NSString *)myurl andDic:(NSDictionary *)myDic;
{
    
        [[LJFNetworkingManager shareManager] POST:myurl parameters:myDic success:^(id returnData, int code, NSString *msg) {
            NSLog(@"%@",msg);
            
            [self.model saveTheBiggestDic:returnData];
            ///这里应该写个判断 判断用户是否是已经完善了自己的个人信息，如果已经完善了 直接跳去tabcontrol ， 如果未完善跳去完善页面再跳tabbarcontrol
                BaseTabBarVC *baseVC = [[BaseTabBarVC alloc]init];
                [self presentViewController:baseVC animated:YES completion:nil];
            
        } failure:^(NSError *error) {
            NSLog(@"%@",error);
        } showHUD:self.view];
        
    
    
    
}


-(void)sendAlertMessage:(NSString *)alerStr
{
    alerStr = [NSString stringWithFormat:@"请选择%@",alerStr];
    [SVProgressHUD showErrorWithStatus:alerStr];
}

-(void)goSaveThePic
{

    
    NSMutableArray * savePicArr = [NSMutableArray new];
    NSMutableArray * userDefaultArr = [NSMutableArray new];
    NSDictionary * newdic = [Tools getValueFromNSUserDefaultsByKey:PICIMG_ARR];
    if (newdic[PICIMG_ARR]!= nil) {
        userDefaultArr = newdic[PICIMG_ARR];
    }
    savePicArr = [NSMutableArray arrayWithArray:userDefaultArr];
    NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString * documentsDirectory = [paths objectAtIndex:0];
    for (int i = 0; i<self.selectPicArry.count; i++) {
        NSData *data2 = UIImageJPEGRepresentation(self.selectPicArry[i], 1.0);
    
        NSLog(@" 1----- documentsDirectory ==== %@",documentsDirectory);
        //    [data1 writeToFile:[homePath stringByAppendingString:@"/Documents/left1.jpg"] atomically:YES];
        NSString * savePicStr = [NSString stringWithFormat:@"Pesronal%d.jpg",i+(int)savePicArr.count+1];
        [data2 writeToFile:[documentsDirectory stringByAppendingPathComponent:savePicStr] atomically:NO];
        
        [savePicArr addObject:savePicStr];
    }
    NSMutableDictionary * savePicDic = [NSMutableDictionary new];
    NSArray * finialArr = [NSArray arrayWithArray:savePicArr];
    
    [savePicDic setValue:finialArr forKey:PICIMG_ARR ];
    [Tools syncNSUserDeafaultsByKey:PICIMG_ARR withValue:(NSDictionary *)savePicDic];

}


#pragma mark UITableViewDatasource,UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if (self.dataArry.count>0) {
        return 1;
    }else
    {
        return  0;
    }
    
    
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArry.count;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    LogFirstTimeTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:logFirstCellID];
    if (!cell) {
        cell = [[LogFirstTimeTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:logFirstCellID];
        
    }
    if (self.dataArry.count>0) {
        [cell reloadTheCellWithIndexPath:indexPath andArray:self.dataArry];
    }
    if (indexPath.row == 0 && ![_MarryTimeStr isEqualToString:@""]) {
        cell.PleaseChoseLabel.text = _MarryTimeStr;
    }
    if (indexPath.row == 1&& ![_dateStr isEqualToString:@""]) {
        cell.PleaseChoseLabel.text = _dateStr;
    }
    if (indexPath.row ==2 && ![_tallStr isEqualToString:@""]) {
        cell.PleaseChoseLabel.text = _tallStr;
    }
    if (indexPath.row ==3 && ![self.areaValue isEqualToString:@""]) {
        cell.PleaseChoseLabel.text = self.areaValue;
    }
    if (indexPath.row == 4&& ![_earnMoneyStr isEqualToString:@""])
    {
        cell.PleaseChoseLabel.text = _earnMoneyStr;
    }
    if (indexPath.row == 5&& ![_workStr isEqualToString:@""]) {
        cell.PleaseChoseLabel.text = _workStr;
    }
    if (indexPath.row == 6&& ![_marryStatus isEqualToString:@""]) {
        cell.PleaseChoseLabel.text = _marryStatus;
    }
    cell.backgroundColor = RGB(245, 245, 247);
    return cell;
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.row == 1) {
        self.backLabel.hidden = NO;
        self.datePickView.hidden = NO;
        self.datePickView.backgroundColor = [UIColor whiteColor];
        self.finishBtn.hidden = NO;
        self.backGrayView.hidden =NO;
        NSDate *select  = [self.datePickView date];
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"yyyy-MM-dd"];
        _dateStr = [dateFormatter stringFromDate:select];
    }else if (indexPath.row == 3)
    {
        self.backLabel.hidden = NO;
        self.backGrayView.hidden = NO;
        self.finishBtn.hidden = NO;
        self.locatePicker = [[HZAreaPickerView alloc] initWithStyle:HZAreaPickerWithStateAndCityAndDistrict delegate:self];
        self.locatePicker.frame = self.myPickView.frame;
        self.areaValue = [NSString stringWithFormat:@"%@ %@ %@", @"上海", @"上海市", @"南汇区"];
        [self.locatePicker showInView:self.view];
    }
    else{
        self.backLabel.hidden = NO;
        self.backGrayView.hidden = NO;
        self.finishBtn.hidden = NO;
        self.pickNewView = [[UIPickerView alloc]initWithFrame:self.myPickView.frame];
        self.pickNewView.backgroundColor = [UIColor whiteColor];
        self.pickNewView.tag = indexPath.row;
        self.pickNewView.delegate =self;
        self.pickNewView.dataSource = self;
        [self.pickNewView selectRow:0 inComponent:0 animated:YES];
        if (indexPath.row == 0) {
            _MarryTimeStr = self.marryedTimeArry[0];
        }else if (indexPath.row == 2)
        {
            _tallStr = self.howTallArry[0];
        }else if (indexPath.row == 4)
        {
            _earnMoneyStr = self.yearMoneyArry[0];
        }else if (indexPath.row == 5 )
        {
            _workStr = self.workArry[0];
        }else if (indexPath.row == 6)
        {
            _marryStatus = self.marryedStatusArry[0];
        }
        [self.view addSubview:self.pickNewView];
    }
    
    NSIndexPath *myindexPath=[NSIndexPath indexPathForRow:indexPath.row inSection:0];
    [self.myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:myindexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark --- 与DataSource有关的代理方法
//返回列数（必须实现）
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}

//返回每列里边的行数（必须实现）
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    //如果是第一列
    if (component == 0) {
        //返回姓名数组的个数
        if (pickerView.tag == 0) {
            return self.marryedTimeArry.count;
        }else if (pickerView.tag ==2)
        {
            return self.howTallArry.count;
        }else if (pickerView.tag == 4)
        {
            return self.yearMoneyArry.count;
        }else if (pickerView.tag ==5)
        {
            return self.workArry.count;
        }
        else if (pickerView.tag == 6)
        {
            return self.marryedStatusArry.count;
        }
        else{
            return self.marryedTimeArry.count;;
        }
        
    }
    else
    {
        return 1;
        //返回表情数组的个数
        //        return self.iconArray.count;
    }
    
}

#pragma mark --- 与处理有关的代理方法
//设置组件的宽度
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
    if (component == 0) {
        return ScreenWidth;
    }
    else
    {
        return 80;
    }
    
}
//设置组件中每行的高度
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
    if (component == 0) {
        return 60;
    }
    else
    {
        return 60;
    }
}
//设置组件中每行的标题row:行
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    if (component == 0) {
        if (pickerView.tag == 0) {
            return self.marryedTimeArry[row];
        }else if (pickerView.tag == 2)
        {
            return self.howTallArry[row];
        }
        else if (pickerView.tag == 4)
        {
            return self.yearMoneyArry[row];
        }
        else if (pickerView.tag == 5)
        {
            return  self.workArry[row];
        }
        else if (pickerView.tag == 6)
        {
            return  self.marryedStatusArry[row];
        }
        else
        {
            return self.marryedTimeArry[row];;
        }
        
    }
    else
    {
        return self.marryedTimeArry[row];
    }
}


//选中行的事件处理
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    

        if (pickerView.tag == 0) {
            NSLog(@"%@",self.marryedTimeArry[row]);
            [pickerView selectedRowInComponent:0];
            _MarryTimeStr = self.marryedTimeArry[row];
        }else if (pickerView.tag ==2)
        {
            NSLog(@"%@",self.howTallArry[row]);
            [pickerView selectedRowInComponent:0];
            _tallStr = self.howTallArry[row];
         
        }
        else if (pickerView.tag == 4)
        {
            NSLog(@"%@",self.yearMoneyArry[row]);
            [pickerView selectedRowInComponent:0];
            _earnMoneyStr = self.yearMoneyArry[row];
            
        }
        else if (pickerView.tag == 5)
        {
            NSLog(@"%@",self.workArry[row]);
            [pickerView selectedRowInComponent:0];
            _workStr = self.workArry[row];
           
        }
        else if(pickerView.tag == 6)
        {
            NSLog(@"%@",self.marryedStatusArry[row]);
            [pickerView selectedRowInComponent:0];
            _marryStatus = self.marryedStatusArry[row];
           
            
        }
       
    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:pickerView.tag inSection:0];
    [self.myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
    
    
}

- (IBAction)sureSexBtnDIdSelected:(UIButton *)sender {
    self.backGrayView.hidden = YES;
    self.myPickView.hidden= YES;
    self.datePickView.hidden =YES;
    self.finishBtn.hidden=YES;
    self.backLabel.hidden=YES;
    self.myTableView.userInteractionEnabled =YES;
    [self.pickNewView removeFromSuperview];
    [self.locatePicker removeFromSuperview];
}


- (IBAction)datepick:(UIDatePicker *)sender {
    NSDate *select  = [sender date];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
   _dateStr = [dateFormatter stringFromDate:select];
    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:1 inSection:0];
    [self.myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
}



#pragma mark - HZAreaPicker delegate
-(void)pickerDidChaneStatus:(HZAreaPickerView *)picker
{
    _hzLocation = picker.locate;
    self.areaValue = [NSString stringWithFormat:@"%@ %@ %@", _hzLocation.state, _hzLocation.city, _hzLocation.district];
    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:3 inSection:0];
    [self.myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];

}

-(void)cancelLocatePicker
{
    [self.locatePicker cancelPicker];
    self.locatePicker.delegate = nil;
    self.locatePicker = nil;
}











/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
